/*
 *  Copyright 2008-2010 www.jrails.org
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.rails.extjs.ajax;

import org.rails.extjs.Observable;
import org.rails.extjs.Parameters;

public abstract class RequestBase extends Observable {

	public RequestBase() {
		super();
	}

	public void setAutoAbort(Boolean autoAbort) {
		addOption("autoAbort", autoAbort);
	}

	public Boolean isAutoAbort() {
		return getBoolean("autoAbort", false);
	}

	public void setDefaultHeaders(Object defaultHeaders) {
		addOption("defaultHeaders", defaultHeaders);
	}

	public Object getDefaultHeaders() {
		return getOption("defaultHeaders");
	}

	public void setDisableCaching(Boolean disableCaching) {
		addOption("disableCaching", disableCaching);
	}

	public Boolean isDisableCaching() {
		return getBoolean("disableCaching", true);
	}

	public void setDisableCachingParam(String disableCachingParam) {
		addOption("disableCachingParam", disableCachingParam);
	}

	public String getDisableCachingParam() {
		return getString("disableCachingParam", "_dc");
	}

	public void setExtraParams(Parameters extraParams) {
		addOption("extraParams", extraParams);
	}

	public Parameters getExtraParams() {
		return (Parameters) getOption("extraParams");
	}


	public void setMethod(String method) {
		addOption("method", method);
	}

	public String getMethod() {
		return getString("method", "");
	}

	public void setTimeout(Integer timeout) {
		addOption("timeout", timeout);
	}

	public Integer getTimeout() {
		return getInteger("timeout", 30000);
	}

	public String getUrl() {
		return getString("url", "");
	}

	public void setUrl(String url) {
		addOption("url", url);
	}

}
